package com.wutuo.tag.provider.dao;

import org.apache.commons.lang3.ObjectUtils;
import org.apache.ibatis.jdbc.SqlBuilder;

import java.util.Map;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;

public class TagRelationsSqlProvider extends BaseTagRelationsSqlProvider {

    public String delRoasterAndTagRelations(Map<String, Object> param) {
        BEGIN();
        SqlBuilder.DELETE_FROM(" tag_relations ");
        if (param.get("tagId") != null) {
            SqlBuilder.WHERE(" tag_id = #{tagId,jdbcType=BIGINT}");
        }

        if (param.get("userId") != null) {
            SqlBuilder.WHERE(" roster_id in (" + ObjectUtils.toString(param.get("userId")) + ")");
        }
        StringBuilder sql = new StringBuilder(SqlBuilder.SQL());
        return sql.toString();
    }

}